package termproject.beans;

import java.sql.*;

public class ConnectionInfoBean
{
	public ConnectionInfoBean () {}
	
	public ConnectionInfoBean (String connectionName, String description, String driver, String url, String username, String password)
	{
		setConnectionName(connectionName);
		setDescription(description);
		setDriver(driver);
		setUrl(url);
		setUsername(username);
		setPassword(password);
	}
	
	public Connection getConnection()
	{
		System.setProperty("jdbc.drivers", driver);
		
		try
		{
			Connection connection = DriverManager.getConnection(url, username, password);
			return connection;
		}
		catch (SQLException e)
		{
			System.err.println("Error connecting: " + e);
			return null;
		}
	}
	
	public void setConnectionName (String connectionName)
	{
		this.connectionName = connectionName;
	}
	
	public void setDescription (String description)
	{
		this.description = description;
	}
	
	public void setDriver (String driver)
	{
		this.driver = driver;
	}
	
	public void setUrl (String url)
	{
		this.url = url;
	}
	
	public void setUsername (String username)
	{
		this.username = username;
	}
	
	public void setPassword (String password)
	{
		this.password = password;
	}
	
	
	public String getConnectionName() { return connectionName; }
	public String getDescription() { return description; }
	public String getDriver() { return driver; }
	public String getUrl() { return url; }
	public String getUsername() { return username; }
	public String getPassword() { return password; }
	
	private String connectionName;
	private String description;
	private String driver;
	private String url;
	private String username;
	private String password;
}